<%--
  Created by IntelliJ IDEA.
  User: wenze-zero
  Date: 2021-06-10-010
  Time: 下午 08:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="java.sql.*" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    try {
        Class.forName ("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    Connection conn = null;
    try {
        conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai", "root", "20010812");
    } catch (SQLException throwables) {
        throwables.printStackTrace();
    }
    out.println("数据库链接成功"+"<br>");
String name=request.getParameter("username");
    Statement stm= null;
    try {
        assert conn != null;
        stm = conn.createStatement();
    } catch (SQLException throwables) {
        throwables.printStackTrace();
    }
    String sql="select * from student where username like '%"+name+"%'";
    ResultSet rs= null;
    try {
        assert stm != null;
        rs = stm.executeQuery(sql);
    } catch (SQLException throwables) {
        throwables.printStackTrace();
    }
%>
<%    while(true){
    try {
        assert rs != null;
        if (!rs.next()) break;
    } catch (SQLException throwables) {
        throwables.printStackTrace();
    }
%>
<tr>
    <td></td>
    <td></td>
    <td></td>
</tr>
<%
    try {
<%=rs.getString("password") %>} catch (SQLException throwables) {
throwables.printStackTrace();
}
try {
<%=rs.getString("username") %>} catch (SQLException throwables) {
throwables.printStackTrace();
}
try {
        } catch (SQLException throwables) {
        throwables.printStackTrace();
        }
        }
            stm.close();
            conn.close();
%>
</body>
</html>
try {
<%=rs.getInt("id") %>} catch (SQLException throwables) {
throwables.printStackTrace();
}